﻿#region 版权信息

//  ------------------------------------------------------------------------------
//   Copyright (C) 成都联宇创新科技有限公司 版权所有。 
//   
//   文件名：LotteryPrize.cs
//   文件功能描述：LotteryPrize.cs
//   创建标识：骆智慧 2014/07/16
//   
//   修改标识：
//   修改描述：
//  ------------------------------------------------------------------------------

#endregion

#region 名称空间导入

using System;
using System.Collections.Generic;
using Castle.ActiveRecord;

#endregion

namespace ECity.Domain
{
    /// <summary>
    ///     奖项
    /// </summary>
    [Serializable]
    [ActiveRecord(Tables.LotteryPrize)]
    public class LotteryPrize : ActiveRecordBase<LotteryPrize>
    {
        /// <summary>
        ///     编号
        /// </summary>
        [PrimaryKey(PrimaryKeyType.Sequence, SequenceName = Sequences.LotteryPrizes)]
        public virtual int ID { get; set; }

        /// <summary>
        ///     参与的抽奖活动
        /// </summary>
        [BelongsTo("SWEEPSTAKE_ID", NotNull = true)]
        public virtual LotterySweepstake Sweepstake { get; set; }

        /// <summary>
        ///     奖项名称
        /// </summary>
        [Property("PRIZE_NAME", NotNull = true)]
        public virtual string PrizesName { get; set; }

        /// <summary>
        ///     奖项代码
        /// </summary>
        [Property("PRIZE_CODE", NotNull = true)]
        public virtual string PrizesCode { get; set; }


        /// <summary>
        ///     奖券面值
        /// </summary>
        [Property("PRIZE_PAR", NotNull = true)]
        public virtual int PrizesPar { get; set; }

        /// <summary>
        ///     奖品总量
        /// </summary>
        [Property("TOTAL_COUNT", NotNull = true)]
        public virtual int TotalCount { get; set; }

        /// <summary>
        ///     奖品剩余数量
        /// </summary>
        [Property("PRIZE_BLANCE", NotNull = true)]
        public virtual int PrizeBlance { get; set; }

        /// <summary>
        ///     是否启用此奖项
        /// </summary>
        [Property("IS_ACTIVED", NotNull = true)]
        public virtual int IsActived { get; set; }

        /// <summary>
        ///     此奖项配置表
        /// </summary>
        [HasMany(typeof (LotteryConfig), ColumnKey = "PRIZE_ID", Table = Tables.LotteryConfig)]
        public virtual IList<LotteryConfig> ConfigList { get; set; }

        /// <summary>
        ///     此奖项中奖记录
        /// </summary>
        [HasMany(typeof (LotteryRecord), Lazy = true, ColumnKey = "PRIZE_ID", Table = Tables.LotteryRecord,
            Where = "PLAY_RESULT=1")]
        public virtual IList<LotteryRecord> WinnerList { get; set; }


        public override int GetHashCode()
        {
            return Tables.LotteryPrize.GetHashCode() ^ ID;
        }
    }
}